<template>
	<el-radio-group v-model="belongDate" size="small" class="item-gap" @change="onChange">
		<el-radio-button :label="getDate(-2)">前天</el-radio-button>
		<el-radio-button :label="getDate(-1)">昨天</el-radio-button>
		<el-radio-button :label="getDate(0)">今天</el-radio-button>
	</el-radio-group>
</template>
<script>
    import { formatDate } from '../../../utils/jk/jk-tool';

    export default {
        model: {
            prop: 'date',
            event: 'change'
        },
        props: {
            date: {
                type: String,
                default: ''
            }
        },
        data() {
            return {
                belongDate: ''
            };
        },
        methods: {
            getDate(e) {
                return formatDate(Date.now() + (e * 24 * 60 * 60 * 1000));
            },
            onChange(e) {
                this.$emit('change', e);
            }
        },
        watch: {
            date: {
                handler(newVal) {
                    this.belongDate = newVal;
                },
                immediate: true
            }
        }
    };
</script>
